# _*_coding:utf-8 _*_
import time

'''字典数据搜索模块'''


# 单条处理函数


def dtpd(jsx, data):
    try:
        for k in jsx:
            if jsx[k] and data[k] != jsx[k]:
                return 0
        return 1
    except Exception as ek:
        print("dtpd单条判断错误:")
        print(ek)
        return 0


# 分页处理


def pali(p, li, data):
    nub = int(p) * int(li)
    if nub < len(data):
        return data[nub - int(li):nub]
    else:
        return data[nub - int(li):]


# 数据搜索


def dictss(data, jsx, p=0, li=0):
    jg = []
    try:
        for i in data:
            if dtpd(jsx, data[i]):
                jg.append(data[i])
        zs = len(jg)
        # print(jg)
        if p and li:
            jg = pali(p, li, jg)

        # print(jg)
        return jg, zs
    except Exception as ek:
        print("dtpd单条判断错误:")
        print(ek)
        return jg, 0
